<template>
	<view>
		<video ref="myVideo" id="myVideo" enable-play-gesture="true" :src="src" :controls="false" loop autoplay
			style="width: 750rpx;" :style="{height: screenHeight + 'px'}" @play="onplay" @error="onerror"
			@timeupdate="timeupdate"></video>
	</view>
</template>

<script>
	export default {
		name: "video",
		props: {
			screenHeight: {
				default: 0
			},
			src: {
				default: false
			},
			playStatus: {
				default: false
			}
		},
		data() {
			return {

			}
		},
		onLaunch: function() {
			// 锁定竖屏  
			plus.screen.lockOrientation("portrait-primary");
		},
		created() {},
		watch: {
			playStatus: function(val) {
				if (!val) {
					uni.createVideoContext('myVideo').pause();
				} else {
					uni.createVideoContext('myVideo').play();
				}
			}
		},
		methods: {
			onplay: function(e) {
				this.$emit("play", 0.1);
			},
			onerror: function(err) {},
			timeupdate: function(e) {
				// if (e.detail.currentTime > 0.2) {
				// 	this.$emit("play", e.detail.currentTime);
				// }
			}
		}
	}
</script>

<style>

</style>
